package com.sskj.mine.presenter;

import com.lzy.okgo.model.Response;
import com.sskj.mine.http.HttpConfig;
import com.sskj.mine.ui.activity.SetPayPwdActivity;
import com.sskj.common.base.HttpData;
import com.sskj.common.util.ToastUtil;
import com.sskj.lib.http.JsonCallBack;


public class SetPayPwdActivityPresenter extends BasePresenter<SetPayPwdActivity> {

    /**
     * 获取短信验证码---codeType 1代表注册  2代表重置密码
     *
     * @param mobile 手机号
     * @return
     */
    public void sendCode(String mobile) {
        httpService.sendCode(mobile, "4", "4", mobile)
                .execute(new JsonCallBack<HttpData>(this) {
                    @Override
                    public void onSuccess(Response<HttpData> response) {
                        HttpData httpData = response.body();
                        ToastUtil.showShort(httpData.msg);
                        if (httpData.getStatus() == HttpConfig.OK) {
                            mView.onSmsResponseSuccess();
                        }
                    }
                });
    }

    /**
     * 设置支付密码
     *
     * @param code     验证码
     * @param tradePwd 支付密码
     * @return
     */
    public void setPayPwd(String code, String tradePwd,String mobile) {
        httpService.setPayPwd(code, tradePwd,mobile)
                .execute(new JsonCallBack<HttpData>(this) {
                    @Override
                    public void onSuccess(Response<HttpData> response) {
                        HttpData httpData = response.body();
                        ToastUtil.showShort(httpData.msg);

                        if (httpData.getStatus() == HttpConfig.OK) {
                            mView.onPayPwdSettingSuccess();
                        }
                    }
                });
    }
}
